﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Input;

namespace TYControl
{
    public class TYIntTextBox : TextBox
    {
        public TYIntTextBox()
        {
            PreviewTextInput += TextBox_PreviewTextInput;
        }

        private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
        {
            int outf = 0;
            e.Handled = !int.TryParse(e.Text, out outf);
        }
    }

    public class UShortTextBox : TextBox
    {
        public UShortTextBox()
        {
            PreviewTextInput += TextBox_PreviewTextInput;
        }

        private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
        {
            ushort outf = 0;
            e.Handled = !ushort.TryParse(e.Text, out outf);
        }
    }
}